﻿<?php
include 'config.sql.php';
include 'function.func.php';
require './libs/Smarty.class.php';
date_default_timezone_set ( 'PRC' );
	$smarty = new Smarty ();
	$smarty->left_delimiter = '<{';
	$smarty->right_delimiter = '}>';
	

$smarty->assign ( 'showIndex', false );
$smarty->assign ( 'polls', true );
$smarty->assign ( 'isLogin', false );
$smarty->assign ( 'loginFailed', false );
$smarty->assign ( 'showResult', false );
$smarty->assign ( 'showMajor', false );
$smarty->assign ( 'glodenMedel', false );
$smarty->assign( 'pollsuccess',false);

$page = isset ( $_REQUEST ['p'] ) ? $_REQUEST ['p'] : "";  //测试一个被设置成 NULL 的变量，将返回 FALSE 

	session_start ();
	if (isset ( $_SESSION ['login'] ) && isset ( $_SESSION ['login'] ) == true)  
		$smarty->assign ( 'isLogin', true );
	if (isset ( $_REQUEST ['username'] ) && isset ( $_REQUEST ['sname'] )) {
			if (login ( $_REQUEST ['username'], $_REQUEST ['sname'] )) {               
				$_SESSION ['login'] = true;
				$_SESSION ['username'] = $_REQUEST ['username'];
				$smarty->assign ( 'isLogin', true );
			} else {
				$smarty->assign ( 'loginFailed', true );
				echo "login failed";
			}              
				
	}



?>
